function things_loading()
{	var HTMLOut = document.getElementById("outDiv").innerHTML;

	HTMLOut += "things loading!" + "<br>";
	document.getElementById('outDiv').innerHTML = HTMLOut;
	
	document.getElementById('textIn').focus();
}

var Thing = new Object;
var NUM_THING = 0;

function makeThing(name,fullname,wearable,firstplace,description,uses)
{
	Thing[NUM_THING] = new Object;
	Thing[NUM_THING].id = NUM_THING;
	Thing[NUM_THING].name = name; // short version of name
	Thing[NUM_THING].fullname = fullname; // full name
	Thing[NUM_THING].wearable = wearable;
	Thing[NUM_THING].firstplace = firstplace; // initial location
	Thing[NUM_THING].description = description;
	Thing[NUM_THING].uses = uses // "verb->object" for combining things

    eval(name + " = Thing[" + NUM_THING + "];");

    NUM_THING++;
}

makeThing("sign", "a wooden sign", false, "inv",
"\"THE END IS NIGH\"", 
"take::[[take_sign()]]"
);
function take_sign()
{
        if( wearing(uniform) )
            return( "You can't be seen carrying that sign around while in uniform.");
        else
        {
            add_to_inv(sign);
            return( "You picked up the sign." );
        }
}

makeThing("lockpicks", "a set of lock picks", false, "inv",
"An aged but serviceable set of lock picking tools.", 
""
);
function lockpick()
{
    if( !is_in_inv(lockpicks) )
    {   say("You don't have your lockpicking tools."); return; }

    if( Token.length == 1 )
    {   say("Pick the lock on what?"); return; }

    if( heroloc().special.indexOf("lockpick::") != -1 )
    {
        var spec = heroloc().special.split("/");

        for( var i = 0; i < spec.length; i++ )
            if( spec[i].split("::")[0] == "lockpick" )
            {   say( spec[i].split("::")[1] ); return; }
    }

    say("That doesn't have a lock you can pick.");
}

makeThing("grappling_gun", "an inoperable grappling gun/a grappling gun", false, "inv",
"Your grappling gun is a useful tool and a work of fine craftmanship.  It was a present from Nite Owl.  Unfortunately it does not stand up well to being used as a bludgeon: it's currently jammed.\
/Your grappling gun is a useful tool and a work of fine craftmanship.  It was a present from Nite Owl.", 
"drop::No.\
/fix::You don't have the mechanical expertise to repair the grappling gun."
);

makeThing("uniform", "your uniform", true, alley,
"Your coat, your hat, your spotless gloves. Your face is folded neatly inside your hat; it stares up at you disapprovingly.", 
"wear::[[wear_uniform()]]\
/unwear::[[wear_uniform()]]\
/drop::No."
);
function wear_uniform()
{
	if( heroloc() != alley )
	    return("You should find a more discreet place to get changed.");

    if( !wearing(uniform) )
    {
        sgs("I_" + uniform.id, 0);
        set_thingloc( uniform, nowhere );

	    sgs("I_" + sign.id, 0);
	    set_thingloc( sign, heroloc() );

	    say("You abandon your disguise and reverently don your coat and hat and face.  It is good to be presentable again, back in your own skin.\n\nYou are now wearing your uniform.");
    }
    else
    {
        add_to_inv(uniform);

        say("You remove your uniform and revert to your civilian guise.");
    }
}

makeThing("handwritten_book", "a book of childish insults", false, warehouse,
"It seems to have been handwritten on letter paper.\
/Every page of this book begins with the words \"Yo mama...\", followed by something obscene. Reading it makes you feel somewhat vindicated.", 
""
);

makeThing("ad", "a mysterious advertisment", false, towerOffice,
"The ad you found on Veidt's desk has a picture of a grinning cartoon crocodile holding a cupcake and a toothbrush. The headline says, \"Sweet news for sharper smiles!\", beneath a blank rectangle labeled \"PRODUCT NAME HERE\". You can't tell what the ad is for, but you don't like it. The crocodile looks communist.", 
""
);

makeThing("laser_pointer", "a laser pointer", false, towerOffice,
"It's surprisingly powerful for a toy.", 
"use->bubastis::[[bubuLaser()]]"
);
function bubuLaser()
{
    if (charloc(bubastis) != heroloc()) {
        say("Bubastis isn't here.");
        return;
    }

    if (gs("bubu1") == 1) {
        sgs("bubu1", 0);
        say("Bubastis becomes fixated on the moving red dot, lashes her tail, and then pounces. She chases the laser beam across the room to where you've aimed it on the far wall, knocking over a jackal-headed bust on a pedestal in the process. The sculpture shatters noisily on the floor.\n\nThe office door opens, and Adrian Veidt walks in. \"Hello, Rorschach.\"");
        set_charloc(adrian, towerOffice);
    } else {
        say("You've already done that.");
    }
}

makeThing("crowbar", "a crowbar", false, nest,
"Short, unyielding, and good for breaking bones. You can respect a crowbar, and you can make other people respect it too.", 
""
);

function things_loaded()
{	var HTMLOut = document.getElementById("outDiv").innerHTML;

	HTMLOut += "things loaded: " + NUM_THING + "<br>";
	document.getElementById('outDiv').innerHTML = HTMLOut;
	
	document.getElementById('textIn').focus();
}